package com.evil.enterprise.controller;

import com.evil.application.api.RemoteApplicationOrderMessageService;
import com.evil.application.pojo.dto.order.message.AddOrderMessageReqDTO;
import com.evil.application.pojo.dto.order.message.OrderMessageReqDTO;
import com.evil.application.pojo.dto.order.message.OrderMessageRespDTO;
import com.evil.common.core.entity.QueryModel;
import com.evil.common.core.entity.R;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 应用订单留言接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/application/order/message")
public class ApplicationOrderMessageController {

    private final RemoteApplicationOrderMessageService remoteApplicationOrderMessageService;

    /**
     * 订单留言
     *
     * @param queryMode queryMode
     * @return R
     */
    @PostMapping("/page")
    public R<PageInfo<OrderMessageRespDTO>> orderMessage(@Validated @RequestBody QueryModel<OrderMessageReqDTO> queryMode) {
        return R.success(remoteApplicationOrderMessageService.orderMessage(queryMode));
    }

    /**
     * 新增订单留言
     *
     * @param addOrderMessageReqDTO addOrderMessageReqDTO
     * @return R
     */
    @PostMapping("/add")
    public R<?> addOrderMessage(@Validated @RequestBody AddOrderMessageReqDTO addOrderMessageReqDTO) {
        remoteApplicationOrderMessageService.addOrderMessage(addOrderMessageReqDTO);
        return R.success();
    }
}
